require("map/rooms/forest/sw_glass_tree")
require("map/rooms/cave/sw_deeper_shadowstone_room")

AddTaskPreInit("MoonIsland_IslandShards", function(task)
    -- 获取 IslandShard 的房间数量函数
    local island_count_fn = task.room_choices["MoonIsland_IslandShard"]

    -- 确定总数（3~5个岛）
    local island_count = type(island_count_fn) == "function" and island_count_fn() or island_count_fn

    -- 确保至少一个岛存在
    if island_count > 0 then
        -- 随机挑选一个岛放置 Sw_Glass_Tree
        local tree_index = math.random(island_count)
        -- 替换逻辑：先把 IslandShard 数量减 1，然后添加一个 Sw_Glass_Tree
        task.room_choices["MoonIsland_IslandShard"] = island_count - 1
        task.room_choices["Sw_Glass_Tree"] = 1
    end
end)

AddRoomPreInit("AtriumMazeEntrance", function(room)
    if room.contents == nil then
        room.contents = {}
    end
    if room.contents.countprefabs == nil then
        room.contents.countprefabs = {}
    end
    room.contents.countprefabs["sw_deeper_shadowstone"] = 1
end)
